﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhouYu.DreamTour.BLL.IService;
using ZhouYu.DreamTour.DAL.IRepository;
using ZhouYu.DreamTour.Model;
using ZhouYu.DreamTour.ViewModel;

namespace ZhouYu.DreamTour.BLL.Service
{
    public class GroupService:IGroupService
    {
        private IGroupRepository _groupRepository;
        public GroupService(IGroupRepository groupRepository)
        {
            _groupRepository = groupRepository;
        }


        /// <summary>
        /// 旅游团购信息展示
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public ResponseResult GetTourList()
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用旅游团购信息展示方法
            responseResult.data= _groupRepository.GetTourList();
            return responseResult;
        }


        /// <summary>
        /// 旅游团购图片展示
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public ResponseResult GetTourPictureList()
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用旅游团购图片展示方法
            responseResult.data= _groupRepository.GetTourPictureList();
            return responseResult;
        }


        /// <summary>
        /// 根据Id获取旅游团购详情信息
        /// </summary>
        /// <param name="TourId"></param>
        /// <returns></returns>
        public ResponseResult GetTourDetailInfoById(int TourId)
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用根据Id获取旅游团购详情信息
            responseResult.data = _groupRepository.GetTourDetailInfoById(TourId);
            return responseResult;
        }


        /// <summary>
        /// 根据订单类型和团购名称来获取人数
        /// </summary>
        /// <param name="TourId"></param>
        /// <returns></returns>
        public ResponseResult GetCount(string Title)
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用根据订单类型和团购名称来获取人数
            responseResult.data = _groupRepository.GetCount(Title);
            return responseResult;
        }


        #region 查询旅游团购的出发城市
        /// <summary>
        /// 查询旅游团购的出发城市
        /// </summary>
        /// <param name="TourId"></param>
        /// <returns></returns>
        public ResponseResult CheckAllStartPlace()
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用查询旅游团购的出发城市
            responseResult.data = _groupRepository.CheckAllStartPlace();
            return responseResult;
        }
        #endregion


        /// <summary>
        /// 根据出发城市筛选旅游团购
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public ResponseResult GetTourInfoByStartPlace(string StartPlace)
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用旅游团购信息展示方法-- 根据出发城市筛选旅游团购
            responseResult.data = _groupRepository.GetTourList().Where(a=>a.StartPlace== StartPlace);
            return responseResult;
        }


    }
}
